function ajax(url) {
  return new Promise((resolve, reject) => {
    const xhr = new XMLHttpRequest();
    xhr.open("GET", url);
    xhr.responseType = "json";
    xhr.onload = function () {
      if (this.status === 200) {
        resolve(this.response);
      } else {
        reject(this.statusText);
      }
    };
    xhr.send();
  });
}

async function main() {
  try {
    const user = await ajax("./api/users.json");
    console.log(user, "main user.json");

    const post = await ajax("./api/posts.json");
    console.log(post, "main post.json");
  } catch (error) {
    console.log(error);
  }
}

const promise = main();
console.log(promise);
